<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01.求婚案例</title>
</head>

<body>
    <script>
        var value = prompt("可以嫁给我么? yes/no")
        var flag = value === 'no' || false
        var count = 2;
        while (flag) {
            if (count % 3 === 2) {
                value = prompt("第" + count + "次求婚，右后我洗完！ yes/no")
            } else if (count % 3 === 0) {
                value = prompt("第" + count + "次求婚，右后我做饭！ yes/no")
            } else if (count % 3 === 1) {
                value = prompt("第" + count + "次求婚，工资都交！ yes/no")
            }
            flag = value === 'no' || false
            if (flag && count === 7) {
                break;
            }
            count++;

        }

        if (flag) {
            alert("次数用尽!")
        } else {
            alert("求婚成功!")
        }
    </script>

</body>

</html>